package com.bmps.springcloud.insuredmicroservice.service.underwrite.strategy.minordeath.riskstrategy;

import com.bmps.springcloud.insuredmicroservice.model.accept.LcPolModel;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * description:
 * HCT010
 *
 * @author jackdaw
 * @date 2020-01-07 19:35
 */
@Component
public class Hct010RiskStrategy implements RiskStrategy {
    @Override
    public BigDecimal getAmount(LcPolModel lcPolModel, List<LcPolModel> lcPolModels, boolean current) {
        BigDecimal yearPrem = lcPolModel.getPayIntv() == 1 ? lcPolModel.getPrem().add(BigDecimal.valueOf(12)) : lcPolModel.getPrem();
        if (18 - lcPolModel.getInsuredAppAge() >= lcPolModel.getPayYears()) {
            //如果（18-被保险人的投保年龄）大于等于缴费期，则未成年人的身故保额设置为年交保费*缴费期*1
            return yearPrem.multiply(BigDecimal.valueOf(lcPolModel.getPayYears()));
        } else if (18 - lcPolModel.getInsuredAppAge() < lcPolModel.getPayYears() && 18 - lcPolModel.getInsuredAppAge() > 0) {
            //如果（18-被保险人的投保年龄）小于缴费期并且大于0，则未成年人的身故保额设置为年交保费*（18-被保险人的投保年龄）*1
            return yearPrem.multiply(BigDecimal.valueOf((18 - lcPolModel.getInsuredAppAge())));
        }
        return BigDecimal.valueOf(0);
    }
}
